<!DOCTYPE html>
<html class="x-admin-sm">
<html lang="en" xmlns:th="http://wwww.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../aaa/css/font.css">
    <link rel="stylesheet" href="../aaa/css/xadmin.css">
    <script src="../aaa/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../aaa/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" action="/samorder/update" method="get">
            <div class="layui-form-item">
                <input type="text" id="orderId" name="orderId" style="display: none" th:value="${sam.orderId}">
                <label class="layui-form-label">
                    <span class="x-red">*</span>审核状态
                </label>
                <div class="layui-input-inline">
                    <select name="statusid" class="layui-input-inline">
                        <option value="0">请选择</option>
                        <option
                                th:each="a:${status}"
                                th:selected="${a.statusid eq sam.statusid}"
                                th:value="${a.statusid}"
                                th:text="${a.statusname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装名
                </label>
                <div class="layui-input-inline">
                    <select name="needId" class="layui-input-inline">
                        <option value="0">请选择</option>
                        <option th:each="a:${need}"
                                th:selected="${a.needId eq sam.needId}"
                                th:value="${a.needId}"
                                th:text="${a.needName}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>分销商
                </label>
                <div class="layui-input-inline">
                    <select name="distributorid" class="layui-input" >
                        <option value="0">请选择</option>
                        <option
                                th:each="a:${dis}"
                                th:selected="${a.distributorid eq sam.distributorid}"
                                th:value="${a.distributorid}"
                                th:text="${a.distributorname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装单价
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Bsprice" name="Bsprice" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input" th:value="${sam.Bsprice}" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>需求数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Bsnumber" name="Bsnumber" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input" th:value="${sam.Bsnumber}" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>负责人
                </label>
                <div class="layui-input-inline">
                    <select name="saadminid" class="layui-input" >
                        <option value="0">请选择</option>
                        <option
                                th:each="a:${emp}"
                                th:selected="${a.emp_id eq sam.saadminid}"
                                th:value="${a.emp_id}"
                                th:text="${a.emp_name}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>生产日期
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="begintime" class="layui-input" id="test1" placeholder="请选择日期" lay-key="1" th:value="${sam.begintimeJs}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>交付日期
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="finishtime" class="layui-input" id="test-1" placeholder="请选择日期" lay-key="1" th:value="${sam.finishtimeJs}">
                </div>
            </div>
            <div class="layui-form-item">
                <center>
                    <button  class="layui-btn layui-btn-radius" lay-filter="add" lay-submit="" style="width: 200px">
                        修改
                    </button>
                </center>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer','jquery'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    var datas=data.field;
                    if (datas.status=="on"){
                        datas.status=0;//正常状态
                    }else {
                        datas.status=1;
                    }
                    $.ajax({
                        url: "/samorder/update",
                        type: "POST",
                        data:datas,
                        success: function (result) {

                            if (result.code==200){
                                layer.msg("修改失败");
                            }
                            else {
                                layer.msg("修改成功",{
                                    icon: 6,
                                    time:500
                                },function() {
                                    parent.window.location.reload();//重新页面
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                });
                            }
                        }, error:function (e) {
                            //返回500错误 或者其他 http状态码错误时 需要在error 回调函数中处理了 并且返回的数据还不能直接alert，需要使用
                            //$.parseJSON 进行转译    res.msg 是自己组装的错误信息通用变量
                            var res = $.parseJSON(e.responseText);
                            layer.msg("修改失败,检查数据填输是否完整,正确");}
                    });
                    return false;
                });


        });
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#test1' //指定元素
        });
        laydate.render({
            elem: '#test-1' //指定元素
        });
    });
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>
